package com.darren.framework.utils;

import java.util.Collection;
import java.util.Map;

public class StringUtil {
	
	public static boolean isEmptyOrWhitespace(String str) {
		if (str == null) return true;
		if ("".equals(str.trim())) return true;
		return false;
	}
	
	public static boolean isSpecialTrue(String value) {
		value = "|" + value + "|";
		return "|on|yes|true|y|t".indexOf(value.toLowerCase()) >= 0;
	}
	
	@SuppressWarnings("rawtypes")
	public static boolean isEmpty(Map map) {
		return isNull(map) || map.size() == 0;
	}
	
	public static boolean isEmpty(String src) {
		return isNull(src) || src.trim().length() == 0;
	}


	public static boolean isEmpty(Object obj) {
		return isNull(obj);
	}
	
	@SuppressWarnings("rawtypes")
	public static boolean isEmpty(Collection col) {
		return isNull(col) || col.size() == 0;
	}
	
	public static boolean isNull(Object obj) {
		return obj == null;
	}
	
	public static String convertNullToEmptyString(Object obj){
		if(obj==null){
			return "";
		}else{
			return obj.toString().trim();
		}
		
	}
}
